package com.kaifamiao.poly;

import java.util.Arrays;

public class TestStudent {

    public static void main(String[] args) {

        Student[] students = new Student[5];
        System.out.println( Arrays.toString( students ) );

        EementarySchoolStudent ess = new EementarySchoolStudent();
        ess.setName( "李小芳" );
        ess.setGender( '女' );
        ess.setAge( 10 );

        students[0] = ess ;

        students[1] = new EementarySchoolStudent();
        students[1].setName( "李大芳" );
        students[1].setGender('女');
        students[1].setAge( 12 );

        MiddleSchoolStudent mss = new MiddleSchoolStudent();
        mss.setName( "陈小婷" );
        mss.setGender('女');
        mss.setAge( 14 );

        students[2] = mss;

        students[3] = new SeniorHighSchoolStudent("王某然", '男', 19 );
        students[4] = new SeniorHighSchoolStudent("李某芳", '女', 18 );

        System.out.println( Arrays.toString( students ) );

        for (int i = 0; i < students.length - 1 ; i++) {
            for (int j = 0; j < students.length - 1 - i ; j++) {
                Student f = students[j];
                Student s = students[j+1];
                if( f.getAge() > s.getAge() ) {
                    students[j+1] = f;
                    students[j] = s;
                }
            }
        }

        System.out.println( Arrays.toString( students ) );

        for (int i = 0; i < students.length; i++) {
            Student s = students[i];
            s.learn( "Java" );
        }

    }

}
